package com.strategy.config;

import com.strategy.aspect.StrategyMonitorAspect;
import com.strategy.manager.StrategyManager;
import com.strategy.service.StrategyService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * 策略框架自动配置类
 */
@Configuration
@EnableAspectJAutoProxy
public class StrategyAutoConfiguration {

    /**
     * 策略管理器（显式指定 @ConditionalOnMissingBean 类型）
     */
    @Bean
    // 显式指定检查 StrategyManager 类型的 Bean 是否存在
    @ConditionalOnMissingBean(StrategyManager.class)
    public StrategyManager strategyManager(StrategyService strategyService) {
        return new StrategyManager(strategyService);
    }

    /**
     * 策略执行监控切面（显式指定 @ConditionalOnMissingBean 类型）
     */
    @Bean
    // 显式指定检查 StrategyMonitorAspect 类型的 Bean 是否存在
    @ConditionalOnMissingBean(StrategyMonitorAspect.class)
    public StrategyMonitorAspect strategyMonitorAspect() {
        return new StrategyMonitorAspect();
    }
}